package com.zjj.learn.designmodel.work.visitor;

/**
 * 计算面积的访问者，提供每一种元素的面积计算方法
 **/
public class AreaCalculator implements Visitor {

    private double area;

    public double getArea() {
        return area;
    }

    @Override
    public void visitRectangle(Rectangle rectangle) {
        area = rectangle.getWidth() * rectangle.getHeight();
    }

    @Override
    public void visitCircle(Circle circle) {
        area = Math.PI * circle.getRadius() * circle.getRadius();
    }

    @Override
    public void visitTextBox(TextBox textBox) {
        // do nothing
    }
}

